🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / connections / src / commonMain / kotlin / org / meshtastic / feature / connections / ui / components / TransportSelector.kt
Displaying Raw • Download
feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/TransportSelector.kt bd2863243bab6eb213401d949839a2bc74dde7e2 (bd286324) Text, 4.57 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.connections.ui.components
Tff7b72import T7ee787androidx.compose.foundation.layout.fillMaxWidth
Tff7b72import T7ee787androidx.compose.foundation.layout.size
Tff7b72import T7ee787androidx.compose.material3.ExperimentalMaterial3Api
Tff7b72import T7ee787androidx.compose.material3.Icon
Tff7b72import T7ee787androidx.compose.material3.SegmentedButton
Tff7b72import T7ee787androidx.compose.material3.SegmentedButtonDefaults
Tff7b72import T7ee787androidx.compose.material3.SingleChoiceSegmentedButtonRow
Tff7b72import T7ee787androidx.compose.material3.SingleChoiceSegmentedButtonRowScope
Tff7b72import T7ee787androidx.compose.material3.Text
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.ui.Modifier
Tff7b72import T7ee787androidx.compose.ui.graphics.vector.ImageVector
Tff7b72import T7ee787org.jetbrains.compose.resources.StringResource
Tff7b72import T7ee787org.jetbrains.compose.resources.stringResource
Tff7b72import T7ee787org.meshtastic.core.model.DeviceType
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.bluetooth
Tff7b72import T7ee787org.meshtastic.core.resources.network
Tff7b72import T7ee787org.meshtastic.core.resources.usb
Tff7b72import T7ee787org.meshtastic.core.ui.icon.Bluetooth
Tff7b72import T7ee787org.meshtastic.core.ui.icon.MeshtasticIcons
Tff7b72import T7ee787org.meshtastic.core.ui.icon.Usb
Tff7b72import T7ee787org.meshtastic.core.ui.icon.Wifi
Tff7b72private Tff7b72const Tff7b72val Te6edf3TRANSPORT_COUNT Tff7b72= T79c0ff3
T8b949e/**
* Single-choice transport selector rendered below the connection card. A Material 3 [SingleChoiceSegmentedButtonRow]
* makes the mutually-exclusive choice explicit: the segments read as one grouped control and the selected transport
* shows a check, rather than three independent chips whose filled state was read as "enabled/available" instead of
* "selected".
*/
Tf0883e@OptInTb4b4b4(Te6edf3ExperimentalMaterial3ApiTff7b72::Te6edf3classTb4b4b4)
Tf0883e@Composable
Tff7b72fun Td2a8ffTransportSelectorTb4b4b4(
Te6edf3activeTransportTb4b4b4: Te6edf3DeviceTypeTb4b4b4,
Te6edf3onSelectTransportTb4b4b4: Tb4b4b4(Te6edf3DeviceTypeTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4,
Te6edf3modifierTb4b4b4: Te6edf3Modifier Tff7b72= Te6edf3ModifierTb4b4b4,
Tb4b4b4) Tb4b4b4{
T8b949e// Fill the width so the control reads as one deliberate group spanning the same width as the connection card
T8b949e// above; each SegmentedButton carries an internal weight(1f), so the three segments divide the row evenly.
Te6edf3SingleChoiceSegmentedButtonRowTb4b4b4(Te6edf3modifier Tff7b72= Te6edf3modifierTb4b4b4.Te6edf3fillMaxWidthTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3TransportSegmentTb4b4b4(
Te6edf3selected Tff7b72= Te6edf3activeTransport Tff7b72=Tff7b72= Te6edf3DeviceTypeTb4b4b4.Te6edf3BLETb4b4b4,
Te6edf3index Tff7b72= T79c0ff0Tb4b4b4,
Te6edf3label Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3bluetoothTb4b4b4,
Te6edf3icon Tff7b72= Te6edf3MeshtasticIconsTb4b4b4.Te6edf3BluetoothTb4b4b4,
Te6edf3onClick Tff7b72= Tb4b4b4{ Te6edf3onSelectTransportTb4b4b4(Te6edf3DeviceTypeTb4b4b4.Te6edf3BLETb4b4b4) Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Te6edf3TransportSegmentTb4b4b4(
Te6edf3selected Tff7b72= Te6edf3activeTransport Tff7b72=Tff7b72= Te6edf3DeviceTypeTb4b4b4.Te6edf3TCPTb4b4b4,
Te6edf3index Tff7b72= T79c0ff1Tb4b4b4,
Te6edf3label Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3networkTb4b4b4,
Te6edf3icon Tff7b72= Te6edf3MeshtasticIconsTb4b4b4.Te6edf3WifiTb4b4b4,
Te6edf3onClick Tff7b72= Tb4b4b4{ Te6edf3onSelectTransportTb4b4b4(Te6edf3DeviceTypeTb4b4b4.Te6edf3TCPTb4b4b4) Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Te6edf3TransportSegmentTb4b4b4(
Te6edf3selected Tff7b72= Te6edf3activeTransport Tff7b72=Tff7b72= Te6edf3DeviceTypeTb4b4b4.Te6edf3USBTb4b4b4,
Te6edf3index Tff7b72= T79c0ff2Tb4b4b4,
Te6edf3label Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3usbTb4b4b4,
Te6edf3icon Tff7b72= Te6edf3MeshtasticIconsTb4b4b4.Te6edf3UsbTb4b4b4,
Te6edf3onClick Tff7b72= Tb4b4b4{ Te6edf3onSelectTransportTb4b4b4(Te6edf3DeviceTypeTb4b4b4.Te6edf3USBTb4b4b4) Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
T8b949e/**
* A single transport segment: shows a check when [selected] and the transport [icon] otherwise, so selection is
* unambiguous while the unselected segments still communicate which transport they represent.
*/
Tf0883e@OptInTb4b4b4(Te6edf3ExperimentalMaterial3ApiTff7b72::Te6edf3classTb4b4b4)
Tf0883e@Composable
Tff7b72private Tff7b72fun Te6edf3SingleChoiceSegmentedButtonRowScopeTb4b4b4.Td2a8ffTransportSegmentTb4b4b4(
Te6edf3selectedTb4b4b4: Tffa657BooleanTb4b4b4,
Te6edf3indexTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3labelTb4b4b4: Te6edf3StringResourceTb4b4b4,
Te6edf3iconTb4b4b4: Te6edf3ImageVectorTb4b4b4,
Te6edf3onClickTb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4,
Tb4b4b4) Tb4b4b4{
Te6edf3SegmentedButtonTb4b4b4(
Te6edf3selected Tff7b72= Te6edf3selectedTb4b4b4,
Te6edf3onClick Tff7b72= Te6edf3onClickTb4b4b4,
Te6edf3shape Tff7b72= Te6edf3SegmentedButtonDefaultsTb4b4b4.Te6edf3itemShapeTb4b4b4(Te6edf3index Tff7b72= Te6edf3indexTb4b4b4, Te6edf3count Tff7b72= Te6edf3TRANSPORT_COUNTTb4b4b4)Tb4b4b4,
Te6edf3icon Tff7b72= Tb4b4b4{
Te6edf3SegmentedButtonDefaultsTb4b4b4.Te6edf3IconTb4b4b4(Te6edf3active Tff7b72= Te6edf3selectedTb4b4b4) Tb4b4b4{
Te6edf3IconTb4b4b4(
Te6edf3imageVector Tff7b72= Te6edf3iconTb4b4b4,
Te6edf3contentDescription Tff7b72= Tff7b72nullTb4b4b4,
Te6edf3modifier Tff7b72= Te6edf3ModifierTb4b4b4.Te6edf3sizeTb4b4b4(Te6edf3SegmentedButtonDefaultsTb4b4b4.Te6edf3IconSizeTb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}Tb4b4b4,
Te6edf3label Tff7b72= Tb4b4b4{ Te6edf3TextTb4b4b4(Te6edf3text Tff7b72= Te6edf3stringResourceTb4b4b4(Te6edf3labelTb4b4b4)Tb4b4b4, Te6edf3maxLines Tff7b72= T79c0ff1Tb4b4b4) Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Served by rngit 1.5.2 - Generated in 0.05s